﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Caculator
{
    public class _2formula
    {
        private double a,b,c=0;
        public double x1,x2;

        public _2formula()
        {
            string xx = Console.ReadLine();   
            a = Convert.ToDouble(xx);
            if (a != 0)
            {
                a =Convert.ToDouble(xx);
            }
            else
            {
                Console.WriteLine("a必须不等于0,请重新输入");
               xx = Console.ReadLine();
                a=Convert.ToInt32(xx);
            }
           xx = Console.ReadLine();
            b = Convert.ToDouble(xx);
           xx = Console.ReadLine();
            c = Convert.ToDouble(xx);
        }

        public void caculate()
        {
            if (b * b - 4 * a * c > 0)
            {
                x1 = (-b+Math.Pow(b * b - 4 * a * c, 0.5))/2*a;
                x2 = (-b - Math.Pow(b * b - 4 * a * c, 0.5)) / 2 * a;
                Console.WriteLine("x1="+ x1 + "    " + "x2="+ x2);

            } else if(b * b - 4 * a * c == 0)
            {
                x1 = -b/2*a;
                x2 = x1;
                Console.WriteLine("x1="+x1+"    "+"x2="+x2);
            } else if (b * b - 4 * a * c < 0)
            {
                Console.WriteLine("无解");
            }

        }
    }
}
